package experiment;

import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;

import javax.swing.*;

public class JOGL implements GLEventListener
{

    public static void main(String[] args)
    {

        //getting the capabilities object of GL2 profile
        final GLProfile profile=GLProfile.get(GLProfile.GL2);
        GLCapabilities capabilities=new GLCapabilities(profile);

        // The canvas
        final GLCanvas glcanvas=new GLCanvas(capabilities);
        JOGL l=new JOGL();
        glcanvas.addGLEventListener(l);
        glcanvas.setSize(400,400);

        //creating frame
        final JFrame frame=new JFrame("JOGL");

        //adding canvas to frame
        frame.add(glcanvas);

        frame.setSize(frame.getContentPane().getPreferredSize());
        frame.setVisible(true);

    }//end of main

    @Override
    public void init(GLAutoDrawable arg0)
    {
        // method body
    }

    @Override
    public void dispose(GLAutoDrawable arg0)
    {
        //method body
    }

    @Override
    public void display(GLAutoDrawable drawable)
    {
        final GL2 gl=drawable.getGL().getGL2();
        gl.glBegin(GL2.GL_LINES);

        //drawing the base
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(-0.50f,-0.50f,0);
        gl.glVertex3f(0.50f,-0.50f,0);
        gl.glEnd();

        //drawing the right edge
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(0f,0.50f,0);
        gl.glVertex3f(-0.50f,-0.50f,0);
        gl.glEnd();

        //drawing the lft edge
        gl.glBegin(GL2.GL_LINES);
        gl.glVertex3f(0f,0.50f,0);
        gl.glVertex3f(0.50f,-0.50f,0);
        gl.glEnd();
        gl.glFlush();
    }

    @Override
    public void reshape(GLAutoDrawable arg0,int arg1,int arg2,int arg3,int arg4)
    {
        // method body
    }

}//end of classimport com.jogamp.opengl.GL2;